package test.zookeeper.test;  

import java.io.IOException;

import org.apache.zookeeper.KeeperException;

import test.zookeeper.ZkServer;
import test.zookeeper.ZkServerImpl;

/**  
 * @类名 ZkTest2.java  
 * @描述: 
 *     TODO
 * @作者 梅光弦  
 * @创建时间 2012-12-4 下午04:34:52  
 * @版本 v1.0  
 */
public class ZkTest2 {

	private static final String hosts="172.0.0.1:2181,172.0.0.1:2182,172.0.0.1:2183";
	
	public static void main(String args[]){
		ZkServer zkServer = new ZkServerImpl();	
		
		try{
			zkServer.init(hosts);
			
			String path = "/App2";
			if(!zkServer.exist(path)){
				zkServer.appendTempNode(path, "Node App2's Data is App2");
				System.out.println("临时节点创建完成");
			}
			
			Thread.sleep(30000);
			
			System.out.println("Session已失效");
			
	    } catch (IOException e) {
		    e.printStackTrace();
	    } catch (KeeperException e) {
		    e.printStackTrace();
	    }	catch (InterruptedException e) {
		    e.printStackTrace();
	    }
	}
	
}
 